#include "../../common/detail.hpp"
#include "../../client/rpc_client.hpp"

void callback(const Json::Value &result)
{
    ILOG("callback result：%d",result.asInt());
}
int main()
{
    //这个地址信息是服务注册中心的
    myrpc::client::RpcClient client(true,"127.0.0.1",8080);
    Json::Value params,result;
    params["num1"]=11;
    params["num2"]=22;

    bool ret=client.call("Add",params,result);
    if(ret!=false)
    {
        std::cout<<result.asInt()<<std::endl;
    }

    myrpc::client::RpcCaller::JsonAsyncResponse res_future;

    params["num1"]=333;
    params["num2"]=333;

    ret=client.call("Add",params,res_future);
    if(ret!=false)
    {
        result=res_future.get();
        std::cout<<result.asInt()<<std::endl;
    }
   
    params["num1"]=333;
    params["num2"]=666;

    ret=client.call("Add",params,callback);
    DLOG("----");
    std::this_thread::sleep_for(std::chrono::seconds(1));
    
    return 0;
}